/*
 * @Descripttion: 
 * @Author: zhangchong zc16607@gmail.com
 * @Date: 2023-02-27 16:08:44
 * @LastEditors: zhangchong zc16607@gmail.com
 * @LastEditTime: 2023-04-24 17:56:44
 */

const express = require('express')
const config = require('./utils/fileDb').initConfig()
// const dbConnect = require('./utils/db')
const initMiddleware = require('./middleware/index')
const routes = require('./routes/index')
const logger = require('./utils/logger')
// let createError = require('http-errors')     // 创建http错误,开发环境使用



const app = express()

// // 错误处理
// app.use('/', (req, res) => {
//   res.status(404).end("can not find " + req.path)
// })


initMiddleware(app)


const PORT = config.port

app.listen(PORT, async () => {
  logger.info(`server listening in http://127.0.0.1:${PORT}`)
  // dbConnect()
  routes(app)

  // app.use(function (req, res, next) {
  //   next(createError(404))
  // })
})
